<?php
session_start();
require_once '../models/Users.php';
require_once '../models/_check_admin.php';
$requestID=$_REQUEST['requestID'];
$row=Users::getRequest($requestID);
if(isset($_POST['btn_submit'])){
$customerID=$row['customerID'];
$money=$row['money'];
$status=$_POST['status'];
$check=true;
if($status=="revoke"){
$re=Users::delRequest($requestID);
if($re) echo "<script>alert('Yêu cầu đã bị xóa!');window.location='request.php'</script>";
	
	else echo "<script>alert('Yêu cầu lỗi!');window.location='request.php'</script>";
}
if($check==true&&$status=="active"){
	$re=Users::updateRequest($customerID,$requestID,$money,$status);
	if($re) echo "<script>alert('Thêm thành công!');window.location='request.php'</script>";
	else echo "<script>alert('Yêu cầu lỗi!');window.location='request.php'</script>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Update Request</title>
<?php include '../admin/_meta.php';?>
</head>
<body>
<form method="post" action="">
	<div id="firstLine">
		<div id="top-bar">
		<?php include '_top_bar_admin.php';?>
		</div>
	</div>
	<div id="container">
		<div id="header">
			<?php include '_menu_admin.php';?>
		</div>
		<div id="center">
				<table id="table-standard">
					<thread>
					<tr>
						<th>Check request</th>
					</tr>
					</thread>
					<tr>
						<td>Customer Name</td>
						<td><lable><?php echo $row['f_name'].' '.$row['l_name']?></lable></td>
					</tr>
					<tr>
						<td>Money</td>
						<td><input type="text" name="money" value="<?php echo $row['money']?>" disabled="disabled" /></td>
						
					</tr>
					<tr>
						<td>Status</td>
						<td><select name="status"><option value='active'>Active</option><option value='revoke'>Revoke</option></select></td>
					</tr>
					<tr>
							<td><input type="submit" class="btn_submit" name="btn_submit" value="Yes"></td>
							<td><a href="request.php"><input type="button" class="btn_submit" name="btn_submit" value="Cancel"></a></td>
						</tr>
				</table>
		</div>
	</div>
	<div>
		<?php include '_footer_admin.php';?>
	</div>
</form>
</body>
</html>